package com.hz.api.admin.web.app;

import com.hz.api.admin.common.Result.ResultInfo;
import com.hz.api.admin.model.request.AddOrEditLolUserRequest;
import com.hz.api.admin.model.request.AddOrEditLolUsersRequest;
import com.hz.api.admin.model.request.NamesRequest;
import com.hz.api.admin.model.request.SetScoreRequest;
import com.hz.api.admin.model.vo.StartTeamingUpVO;
import com.hz.api.admin.web.config.aop.annotation.OperateLogAnnotation;
import com.hz.api.admin.web.constant.Constants;
import com.hz.api.admin.web.service.LOLService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author liusu
 */
@RestController
@RequestMapping("/api/v1/LOL")
@Tag(name = "LOL用户管理")
public class LOLController {

    @Resource
    private LOLService lolService;

    @PostMapping("/startTeamIngUp")
    @Operation(summary = "开始组队")
    public ResultInfo<StartTeamingUpVO> startTeamIngUp(@RequestBody NamesRequest names) {
        return ResultInfo.buildSuccess(lolService.startTeamIngUp(names.getSelectedNames()));
    }

    @PostMapping("/rankUsers")
    @Operation(summary = "获取所有LOL用户列表")
    public ResultInfo rankUsers() {
        return ResultInfo.buildSuccess(lolService.getLolRankUsers());
    }

    @PostMapping("/setScore")
    @Operation(summary = "设置分数")
    @OperateLogAnnotation(modularType = Constants.LOL_SET_SCORE,modularName = "LOL分数",scene = "修改分数")
    public ResultInfo setScore(@RequestBody SetScoreRequest names) {
        lolService.setScore(names);
        return ResultInfo.success();
    }

    @PostMapping("/addOrEditUser")
    @Operation(summary = "新增或编辑LOL人员")
    @OperateLogAnnotation(modularType = Constants.LOL_ADD_OR_EDIT_USER,modularName = "LOL用户",scene = "新增或编辑")
    public ResultInfo addOrEditUser(@RequestBody AddOrEditLolUserRequest request) {
        lolService.addOrEditUser(request);
        return ResultInfo.success();
    }
  @PostMapping("/addOrEditUsers")
  @Operation(summary = "批量编辑LOL胜场")
  @OperateLogAnnotation(modularType = Constants.LOL_ADD_OR_EDIT_USER,modularName = "LOL用户",scene = "批量编辑战绩")
  public ResultInfo addOrEditUsers(@RequestBody AddOrEditLolUsersRequest request) {
    lolService.addOrEditUsers(request);
    return ResultInfo.success();
  }


    @PostMapping("/deleteUser")
    @Operation(summary = "删除LOL人员")
    @OperateLogAnnotation(modularType = Constants.LOL_DELETE_ADD_USER,modularName = "LOL用户",scene = "删除")
    public ResultInfo deleteUser(@RequestParam("id") Long id) {
        lolService.deleteLOLUser(id);
        return ResultInfo.success();
    }
}
